
document.observe("dom:loaded", loadMain);
var strPathLink_All = "http://www.nhommua.com/tp-ho-chi-minh/";


function loadMain() {

    //document được scroll
    if ($("dvBackToTop")) {
        if (document.all == null || document.all == "undefined") {
            document.onscroll = setVisibleBackToTop;
        }
        else {
            document.body.onscroll = setVisibleBackToTop;
            window.onscroll = setVisibleBackToTop;
        }
    }
    //city list
    if ($("aSelectCity")) {
        $("aSelectCity").onclick = setVisibleBoxCityRunDeal;
    }
    //my account
    if ($("aUserProfile")) {
        $("aUserProfile").onclick = setVisibleUserMenu;
    }
    //nhan gia tot
    if ($("btnInsertEmailGiaTot")) {
        $("btnInsertEmailGiaTot").onclick = insertEmailNhanGiaTot;
    }
    if ($("txtEmailTopBanner")) {
        $("txtEmailTopBanner").onkeypress = PressKey;
    }
    //nhan deal mỗi ngày
    if ($("txtEmailSendNewDeal")) {
        $("txtEmailSendNewDeal").onkeypress = PressKey;
    }
    if ($("btnInsertEmailNewDeal")) {
        $("btnInsertEmailNewDeal").onclick = insertEmailNhanNewDeal;
    }
    //so luong
    if ($("dvGioHang")) {
        eventSelectSoLuong();
    }

    if ($("ddlSL_0")) {

        if (!$("dvGioHang")) {
            $("ddlSL_0").onchange = onChangePricePopUp_DDL;
        }

        var iSLMua_old = 1;
        if (GetCookie("SLMua")) {
            iSLMua_old = parseInt(GetCookie("SLMua"));
        }
        iSLMua_old = iSLMua_old > parseInt(strBuyDeal.slmua) ? parseInt(strBuyDeal.slmua) : iSLMua_old;
        $("ddlSL_0").value = iSLMua_old;
        if ($("dvGioHang")) {
            var strUrlLocation = window.location.href;
            strUrlLocation = strUrlLocation.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
            var strUrlLink = strPathLink_All.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
            if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
                strUrlLink = strPathLink_All + "yahoo/";
            }
            utils.call(strUrlLink + strStateNM + "/buy-deals.aspx", { "flag": "SPYeuThich", "id": strBuyDeal.id, "strPAID": iSLMua_old }, "POST", null, null);
        }
        var DonGia = strBuyDeal.giaban;
        var SoDuTK = iMyMoney;
        var ThanhTien = iSLMua_old * DonGia;
        var TongTien = ThanhTien;

        if (SoDuTK > TongTien) {
            TongTien = 0;
            SoDuTK = SoDuTK - TongTien;
        }
        else {
            TongTien = TongTien - SoDuTK;
            SoDuTK = 0;
        }
        $("spnTongGia").innerHTML = ConvertToMoney(ThanhTien);
        $("pTotal").innerHTML = (strLangNM == "en" ? langMess_en()[0][43] : langMess()[0][43]) + ConvertToMoney(TongTien) + " VNĐ";
        
    }
    
    if ($("dkNhanGiaTotQuaEmail")) {
        $("dkNhanGiaTotQuaEmail").onclick = showPopupDKNhanGiaTot;
    }
    if ($("btnSubmitDKNhanGiaTot")) {
        $("btnSubmitDKNhanGiaTot").onclick = insertEmailDKNhanGiaTot;
    }
    if ($("txtEmailDKNhanGiaTot")) {
        $("txtEmailDKNhanGiaTot").onfocus = setTxtFocus;
        $("txtEmailDKNhanGiaTot").onblur = setTxtLostFocus;
        $("txtEmailDKNhanGiaTot").onkeypress = PressKey_DKNhanGiaTot;
    }
    if ($("ddlThanhPho")) {
        $("ddlThanhPho").onfocus = setTxtFocus;
        $("ddlThanhPho").onblur = setTxtLostFocus;
        $("ddlThanhPho").onkeypress = PressKey_DKNhanGiaTot;
    }

    /*chay slide trang gia tot hom nay*/
    if ($("dListIMGSlideShow")) {
        setTimeout("setSlider();", 3000);

    }
    /*chay time count down*/
    if ($("imgShow2") || $("dListDeal")) {
        if (arrRemainTime.length > 0 && !$("ddlSL_Luxury")) {
            TimeCountDown_List();
        }
    }
    
    innerShareBottom();
        
    if ($("div_hotPhone")) {
        setDivHotPhone();
    }
    resizeBox();

    /*luxury*/
    if ($("dPaging_top") || $("ddlSL_Luxury") || $("dCompanyInfo")) {
        init_Luxury();
    }

    /*end luxury*/

    if ($("dBoxFacebook")) {
        var objBrowser = navigator.appVersion;
        if (objBrowser.indexOf('MSIE') != -1) {
            var ga = document.createElement('iframe'); ga.async = true;
            //ga.src = 'http://www.facebook.com/profile.php?id=100000255925709';
            //ga.setAttribute("src", "http://static.ak.fbcdn.net/rsrc.php/v1/y-/r/_fpOplCGGOR.js");
            ga.setAttribute('src', 'http://www.facebook.com/profile.php?id=100000255925709');
            ga.setAttribute('height', '0px');
            ga.setAttribute('width', '0px');

            //12.11
            if (ga.attachEvent) {
                ga.attachEvent("onload", setVisibleBoxFacebook);
            }
            else {
                ga.onload = setVisibleBoxFacebook;
            }
            //12.11

            document.body.appendChild(ga);
        }
        else {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = 'http://www.facebook.com/profile.php?id=100000255925709';
            //ga.src = 'http://static.ak.fbcdn.net/rsrc.php/v1/y-/r/_fpOplCGGOR.js';                
            ga.setAttribute("height", "0px");
            ga.setAttribute("width", "0px");

            //12.11
            if (ga.attachEvent) {
                ga.attachEvent("onload", setVisibleBoxFacebook);
            }
            else {
                ga.onload = setVisibleBoxFacebook;
            }
            //12.11

            document.body.appendChild(ga);
                     
        }
    }

}

function setVisibleBoxFacebook() {
    innerFacebook();
    $('dBoxFacebook').style.display = "block";
}
//set display cho BackToTop
function setVisibleBackToTop() {
    var iTop = 0;
    if (document.body.scrollTop) {
        iTop = document.body.scrollTop;    }
    else {
        iTop = document.documentElement.scrollTop;        
    }
    $("dvBackToTop").style.display = iTop > 0 ? "block" : "none";
    //$("dvBackToTop").style.display = (document.documentElement.scrollTop) > 0 ? "block" : "none";
} 
/************************************************/
window.onresize = function() {
    try {
        resizeBox();
    } catch (ex) { }
};
/***********************************************/
// set city run deal
function setVisibleBoxCityRunDeal() {
    if ($("dBoxCityRunDeal").style.display == "none") {
        $("dBoxCityRunDeal").style.display = "block";
        $("hCityName").style.display = "none";
    }
    else {
        $("dBoxCityRunDeal").style.display = "none";
        $("hCityName").style.display = "block";
    }
}
//hiển thị my account menu
function setVisibleUserMenu() {
    if ($("dUserMenu").style.display == "none") {
        $("aUserProfile").addClassName("profile_act");
        $("dUserMenu").style.display = "block";
    }
    else {
        $("aUserProfile").removeClassName("profile_act");
        $("dUserMenu").style.display = "none";
    }
}
//ẩn my account menu
function setInvisibleUserMenu() {
    if ($("dUserMenu").style.display == "block") {
        $("aUserProfile").removeClassName("profile_act");
        $("dUserMenu").style.display = "none";
    }
}
//insert email nhận giá tốt
function insertEmailNhanGiaTot() {
    if (checkMail($("txtEmailTopBanner").value) == true) {
        $("txtEmailTopBanner").onkeypress = "";
        if ($("btnInsertEmailGiaTot")) {
            $("btnInsertEmailGiaTot").onclick = "";  //insertEmailNhanGiaTot;
        }
        var strUrlLocation = window.location.href;
        strUrlLocation = strUrlLocation.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
        var strUrlLink = strPathLink_All.replace('tp-ho-chi-minh/', '').replace('ha-noi/', ''); 
        if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
            strUrlLink = strPathLink_All + "yahoo/";
        }

        utils.call(strUrlLink + strStateNM + "/gia-tot-hom-nay.html", { "flag": "InsertEmailNhanGiaTot", "email": $("txtEmailTopBanner").value, "city": strStateNM }, "POST", "insertEmailGiaTotResult", "insertEmailGiaTotResult");
    }
    else {
        var msg = (utils.trim($('txtEmailTopBanner').value) == "") ? "Bạn chưa nhập địa chỉ email" : "Email của bạn không đúng định dạng";
        try {
            showErrorRegister('msgError', 'false', msg, 'block');
        }
        catch (e) {
          
        }
    }
}
//insert email nhận deal mỗi ngày
function insertEmailNhanNewDeal() {
    if (checkMail($("txtEmailSendNewDeal").value) == true) {
    
        $("txtEmailSendNewDeal").onkeypress = "";
        if ($("btnInsertEmailNewDeal")) {
            $("btnInsertEmailNewDeal").onclick = ""; //nsertEmailNhanNewDeal;
        }
        var strUrlLocation = window.location.href;
        strUrlLocation = strUrlLocation.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
        var strUrlLink = strPathLink_All.replace('tp-ho-chi-minh/', '').replace('ha-noi/', ''); 
        if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
            strUrlLink = strPathLink_All + "yahoo/";
        }

        utils.call(strUrlLink + strStateNM + "/gia-tot-hom-nay.html", { "flag": "InsertEmailNhanGiaTot", "email": $("txtEmailSendNewDeal").value, "city": city }, "POST", "insertEmailGiaTotResult", "insertEmailGiaTotResult");
    }
    else {
        var msg;
//        if (strLangNM == 'vi') {
//            msg = (utils.trim($('txtEmailSendNewDeal').value) == "") ? langMess()[0][24] : langMess()[0][4];
//        }
//        else if (strLangNM == 'en') {
//            msg = (utils.trim($('txtEmailSendNewDeal').value) == "") ? langMess_en()[0][24] : langMess_en()[0][4];
//        }
        msg = (utils.trim($('txtEmailSendNewDeal').value) == "") ? langMess()[0][24] : langMess()[0][4];
        try {
            showErrorRegister('msgError', 'false', msg, 'block');
        }
        catch (e) {
            //alert(msg);
        }
    }
}
//nhận kq trả về sau khi insert email nhận giá tốt hoặc deal mỗi ngày
function insertEmailGiaTotResult(obj) {
    //edit 29/9/2011
    //edit
    if ($("txtEmailTopBanner")) {
        $("txtEmailTopBanner").value = "";
        $("txtEmailTopBanner").onkeypress = PressKey;
    }
    if ($("txtEmailSendNewDeal")) {
        $("txtEmailSendNewDeal").value = "";
        $("txtEmailSendNewDeal").onkeypress = PressKey;
    }
    if ($("btnInsertEmailGiaTot")) {
        $("btnInsertEmailGiaTot").onclick = insertEmailNhanGiaTot;
    }
    if ($("btnInsertEmailNewDeal")) {
        $("btnInsertEmailNewDeal").onclick = insertEmailNhanNewDeal;
    }
    if ($("txtEmailDKNhanGiaTot")) {
        $("txtEmailDKNhanGiaTot").value = "";
    }
    if ($("dvShahowDKNhanGiaTot")) {
        $("dvShahowDKNhanGiaTot").setStyle({ display: "none" });
    }
    if ($("dvPopupDKNhanGiaTot")) {
        $("dvPopupDKNhanGiaTot").addClassName("hide");
    }

    try {
        if (parseInt(obj) == 1) {
            showErrorRegister('msgError', 'true', (strLangNM == "en" ? langMess_en()[0][26] : langMess()[0][26]), 'block');
        } else {
            showErrorRegister('msgError', 'false', (strLangNM == "en" ? langMess_en()[0][27] : langMess()[0][27]), 'block');
        }
    }
    catch (e) {
        //alert("Email của bạn đã cập nhật thành công")
    }
    
    //alert("-Cám ơn bạn đã nhập Email, nhómMua.com sẽ gửi mail cho bạn khi có Deal mới!, Bạn vui lòng bỏ email 'info@nhommua.com' vào address book để đảm bảo bạn sẽ nhận email từ nhomMua.com! Nếu không email có thể sẽ vào SPAM/BULK.");
    
    //end edit
}
	
//xử lý sự kiện focus
function setTxtFocus(e) {
    var eID = utils.getElementFireEvent(e);
    //try { $(document.forms[0]).select('div.txt-focus').invoke('removeClassName', 'txt-focus'); } catch (e) { }
    try {$($(eID).up(0)).addClassName("txt-focus"); } catch (e) { }
}
//xử lý sự kiện lost focus
function setTxtLostFocus(e) {
    var eID = utils.getElementFireEvent(e);
    //try { $(document.forms[0]).select('div.txt-focus').invoke('removeClassName', 'txt-focus'); } catch (e) { }
    try { $($(eID).up(0)).removeClassName("txt-focus"); } catch (e) { }
    if (eID.id == "txtSUNick") {
        checkNickName();
    }
}
//hien thi popup loi tu tu
var hx = 0;
var timeout_id;
var iSubFolder;
function showErrorRegister(id, status, strMess, display) {
    //$(id).update(strMess);
    if (status == 'true') 
    {   

        var html = ' <p class="success">'+
                                '<span class="pop-up-img"></span>' +
                                '<span>'+strMess+'</span>'+
                            '</p>';
        $("pError").innerHTML = html;
                            
    }
    else 
    {
        $("pError").innerHTML = '<p>' +
                                '<span class="pop-up-img"></span>' +
                                '<span>'+strMess+'</span>' +
                            '</p>';
    }
    
    top.scroll(0, 0);
    try {showPopupError(); } catch (e) { }
}
function showPopupError() {
    clearTimeout(timeout_id);
    if (hx <= 67) {
        hx = hx + 7;
        $("pError").setStyle({ height: (hx).toString() + "px", display: "block" });
        timeout_id = setTimeout("showPopupError()", 50);
    } else hx = 0;
}
//nhận kết quả kiểm tra Session đăng nhập
var objLogin = null;
var url = (document.location.href).toLowerCase();
function checkSessionResult(objUser) {
    
    if (objUser != "0") {
        if (typeof (objUser) == "object") {
            objLogin = objUser;
        }
    }
}
//kiểm tra Session đăng nhập
function checkSession() {
    var strUrlLocation = window.location.href;
    strUrlLocation = strUrlLocation.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
    var strUrlLink = strPathLink_All.replace('tp-ho-chi-minh/', '').replace('ha-noi/', ''); 
    if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
        strUrlLink = strPathLink_All + "yahoo/";
    }    
    utils.call(strUrlLink + strStateNM + "/login.aspx", { "flag": "checksession" }, "POST", "checkSessionResult", "checkSessionResult");
}

var flagOrderInfo = 0;
//thay doi gia khi chon so luong mua
function onChangePricePopUp_DDL() {

    var SLMua = $("ddlSL_0").value;
    var DonGia = strBuyDeal.giaban;
    var SoDuTK = iMyMoney;
    SetCookie("SLMua", SLMua, 60);

    var ThanhTien = SLMua * DonGia;
    var TongTien = parseInt(ThanhTien) - parseInt(SoDuTK);
    $("spnTongGia").innerHTML = ConvertToMoney(ThanhTien);
    $("pTotal").innerHTML = (strLangNM == "en" ? langMess_en()[0][43] : langMess()[0][43]) + ConvertToMoney(TongTien) + " VNĐ";
    
}
//giatothomnay.aspx

//xử lý sự kiện enter
function PressKey(e) {
    var evt = e ? e : window.event;
    var bt = $(this.id);
    if (bt) {
        if (evt.keyCode == "13" || evt.which == "13" || evt.charCode == "13") {
            try { bt.click(); } catch (e) { }
            switch (this.id) {
                case "txtMaOrder":
                    clickViewOrder();
                    break;
                    
                //đăng nhập
                //edit 04/10/2011
                case "txtSIEmail": case "txtSIPass":
                    checkLoginSI(); 
                    break;
                //end edit

                //Nhận giá tốt (nhận deal mỗi ngày) 
                //edit 24/9/2011
                case "txtEmailTopBanner":
                    insertEmailNhanGiaTot(); //insertEmailGiaTot();
                    break;
                case "txtEmailSendNewDeal":
                    insertEmailNhanNewDeal();
                    break;
                //end edit 
                
                case "txtProService": case "txtPercent":
                    insertDeNghi();
                    break;
                case "txtResetRPass": case "txtResetPass":
                    resetPass();
                    break;
                case "txtEmail": case "txtPass":
                    checkLogin();
                    break;
                case "txtPEMail": case "txtPPass":
                    checkLoginPopUp();
                    break;
                    
                //đăng ký nhanh
                //edit 29/9/2011
                case "txtSUBName": case "txtSUBEmail": case "txtSUBPass": case "txtSUBRePass":
                    SignUpBuy();
                    break;
                //end edit 
                
                //đăng ký
                //edit 29/9/2011
                case "txtSUName": case "txtSUNick": case "txtSUEmail": case "txtSUPass": case "txtSURePass":
                    SignUp(); //đăng ký
                    break;
                case "ddlDate": case "ddlMonth": case "ddlYear":
                    if ($("txtSUName") && $("txtSUNick") && $("txtSUEmail") &&
                        $("txtSUPass") && $("txtSURePass") && $("cbMale") && $("cbFemale") &&
                        $("ddlDate") && $("ddlMonth") && $("ddlYear")) {
                        SignUp(); //đăng ký
                    }
                    break;
                case "txtCapcha":
                    if ($("txtSUName") && $("txtSUNick") && $("txtSUEmail") &&
                        $("txtSUPass") && $("txtSURePass") && $("cbMale") && $("cbFemale") &&
                        $("ddlDate") && $("ddlMonth") && $("ddlYear")) {
                        SignUp(); //đăng ký
                    }
                    else if ($("txtForgotPass"))
                    {   
                        sendLostPass(); //reset mật khẩu
                    }
                    break;
                    
                //reset mật khẩu
                //edit
                case "txtForgotPass":
                    sendLostPass(); //reset mật khẩu
                    break;
                //end edit
            }
            return false;
        }
    }
}
/***************************************************************************************************/
function getQueryStringValue(value) {

    var listQuery = new Array();
    var query_value = "";
    listQuery = window.location.search.substring(1).split('&');
    for (var i = 0; i < listQuery.length; i++) {
        if (listQuery[i].indexOf(value) != -1) {
            query_value = listQuery[i].split('=')[1];
        }
    }

    return query_value;

}
/***************************************************************************************************/
function trim(str) {
    str = str.replace(/\s+/g, '');
    return str;
}

/***************************************************************************************************/
function showPopupDKNhanGiaTot() {

    var h = document.documentElement.scrollHeight;
    var w = document.documentElement.scrollWidth;
    //var l = (w - $("dvPopupDKNhanGiaTot").getWidth()) / 2;

    $("dvShahowDKNhanGiaTot").setStyle({ width: w.toString() + "px", height: h.toString() + "px", display: "block" });
    //$("dvPopupDKNhanGiaTot").setStyle({ top: "50px", left: l.toString() + "px" });
    $("dvPopupDKNhanGiaTot").setStyle({ top: "50px" });

    window.onresize = function() {
        var w = document.documentElement.clientWidth;
        $(document.body).style.width = (w <= 990) ? "990px" : "";
        if ($("dvShahowDKNhanGiaTot")) {
            $("dvShahowDKNhanGiaTot").setStyle({ width: (w <= 990) ? "990px" : "auto" });
        }
    };
    javascript: window.scrollTo(0, 0);
    $("dvPopupDKNhanGiaTot").removeClassName("hide");
    $("btnCloseDKNhanGiaTot").onclick = hidePopupDKNhanGiaTot;
    $("txtEmailDKNhanGiaTot").focus();
}

/***************************************************************************************************/
function insertEmailDKNhanGiaTot() {
    if (checkMail($("txtEmailDKNhanGiaTot").value) == true) {

        if ($('ddlThanhPho').selectedIndex != 0) {
            $("spMsgDKNhanGiaTot").innerHTML = "";
            $("spMsgDKNhanGiaTot").setStyle({ display: "none" });

            var email = $("txtEmailDKNhanGiaTot").value;
            var strUrlLocation = window.location.href;
            strUrlLocation = strUrlLocation.replace('tp-ho-chi-minh/', '').replace('ha-noi/', '');
            var strUrlLink = strPathLink_All.replace('tp-ho-chi-minh/', '').replace('ha-noi/', ''); 
            if (strUrlLocation.toLowerCase().indexOf("/yahoo/") != -1) {
                strUrlLink = strPathLink_All + "yahoo/";
            }                       
            var city = $('ddlThanhPho').value;
            utils.call(strUrlLink + strStateNM + "/gia-tot-hom-nay.html", { "flag": "InsertEmailDKNhanGiaTot", "email": email, "city": city }, "POST", "insertEmailGiaTotResult", "insertEmailGiaTotResult");
        }
        else {
            //chua chon tp
            $("spMsgDKNhanGiaTot").innerHTML = "Xin chọn thành phố";
            $("spMsgDKNhanGiaTot").setStyle({ display: "block" });
            $("ddlThanhPho").focus();
        }
    }
    else {
        //sai email
        $("spMsgDKNhanGiaTot").innerHTML = "Email không hợp lệ";
        $("spMsgDKNhanGiaTot").setStyle({ display: "block" });
        $("txtEmailDKNhanGiaTot").focus();
    }
}
/***************************************************************************************************/
function hidePopupDKNhanGiaTot() {
    if ($("dvShahowDKNhanGiaTot")) {
        $("dvShahowDKNhanGiaTot").setStyle({ display: "none" });
    }
    if ($("dvPopupDKNhanGiaTot")) {
        $("dvPopupDKNhanGiaTot").addClassName("hide");
    }
}
/***************************************************************************************************/
function PressKey_DKNhanGiaTot(e) {
    var evt = e ? e : window.event;
    var bt = $(this.id);
    if (bt) {
        if (evt.keyCode == "13" || evt.which == "13" || evt.charCode == "13") {
            try { bt.click(); } catch (e) { }
            switch (this.id) {

                case "txtEmailDKNhanGiaTot": case "ddlThanhPho":
                    insertEmailDKNhanGiaTot();
                    break;
            }
            return false;
        }
    }
}
/***************************************************************************************************/

//edit 29/9/2011
// kiểm tra khi enter trước khi goi hàm SignUp()
function checkBeforeSignUp(i) {

    if (i <= 2 && $("txtSUNick") && utils.trim($('txtSUNick').value) == "") {
        $("txtSUNick").focus();
    }
    else if (i <= 3 && $("txtSUEmail") && utils.trim($('txtSUEmail').value) == "") {
        $("txtSUEmail").focus();
    }
    else if (i <= 4 && $("txtSUPass") && utils.trim($('txtSUPass').value) == "") {
        $("txtSUPass").focus();
    }
    else if (i <= 5 && $("txtSURePass") && utils.trim($('txtSURePass').value) == "") {
        $("txtSURePass").focus();
    }
    else if (i <= 6 && $("txtCapcha") && utils.trim($('txtCapcha').value) == "") {
        $("txtCapcha").focus();
    }
    else {
        SignUp();
    }
}
// kiểm tra khi enter trước khi goi hàm SignUpBuy()
function checkBeforeSignUpBuy(i) {

    if (i <= 2 && $("txtSUBEmail") && utils.trim($('txtSUBEmail').value) == "") {
        $("txtSUBEmail").focus();
    }
    else if (i <= 3 && $("txtSUBPass") && utils.trim($('txtSUBPass').value) == "") {
        $("txtSUBPass").focus();
    }
    else if (i <= 4 && $("txtSUBRePass") && utils.trim($('txtSUBRePass').value) == "") {
        $("txtSUBRePass").focus();
    }
    else {
        SignUpBuy();
    }
}

/******************************************************************************/
function innerFacebook() {
    var html = "";
    switch (iCityID) {
        case 8:
            html += "<div class='box-transparent-content'>";
            html += "<iframe src='http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FNhomMua%2F150063235035057&amp;width=928&amp;colorscheme=light&amp;show_faces=true&amp;border_color=0&amp;stream=false&amp;header=false&amp;height=183' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:928px; height:183px;' allowTransparency='true' id='Facebook_Iframe'></iframe>";
            html += "</div>";
            break;
        case 4:
            html = "";
            html += "<div class='box-transparent-content'>";
            html += "<iframe src='http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FNhomMua.Hanoi&amp;width=928&amp;colorscheme=light&amp;show_faces=true&amp;border_color=0&amp;stream=false&amp;header=false&amp;height=183' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:928px; height:183px;' allowTransparency='true' id='Facebook_Iframe'></iframe>";
            html += "</div>";
            break;
        case 710:
            html = "";
            html += "<div class='box-transparent-content'>";
            html += "<iframe src='http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FNhomMua.Cantho&amp;width=928&amp;colorscheme=light&amp;show_faces=true&amp;border_color=0&amp;stream=false&amp;header=false&amp;height=183' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:928px; height:183px;' allowTransparency='true' id='Facebook_Iframe'></iframe>";
            html += "</div>";
            break;
    }
    $("dBoxFacebook").innerHTML = html;

}
 /******************************************************************************/
 function innerShareBottom() {
     if ($("dSharingBottom")) {
         var html = "";
         var ViewLink = "http://www.nhommua.com";
         switch (iCityID) {
             case 8:
                 $("dZingSharingBottom").innerHTML = "<a href='http://link.apps.zing.vn/share?url=http://www.nhommua.com/tp-ho-chi-minh/'><img src='http://www.mjgroup.com.vn/images_v2/zing.png' target='_blank' width='21' height='21' /></a>";
                 $("dFacebookSharingBottom").innerHTML = '<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FNhomMua%2F150063235035057&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:112px; height:21px;padding-top:0px;" allowTransparency="true"></iframe>';
                 break;
             case 4:
                 $("dZingSharingBottom").innerHTML = "<a href='http://link.apps.zing.vn/share?url=http://www.nhommua.com/ha-noi/' ><img src='http://www.mjgroup.com.vn/images_v2/zing.png' target='_blank' width='21' height='21' /></a>";
                 $("dFacebookSharingBottom").innerHTML = '<iframe src="http://www.facebook.com/plugins/like.php?app_id=230521913657215&amp;href=http%3A%2F%2Fwww.facebook.com%2FNhomMua.Hanoi&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>';
                 break;
             case 710:
                 $("dZingSharingBottom").innerHTML = "<a href='http://link.apps.zing.vn/share?url=http://www.nhommua.com/can-tho/' ><img src='http://www.mjgroup.com.vn/images_v2/zing.png' target='_blank' width='21' height='21' /></a>";
                 $("dFacebookSharingBottom").innerHTML = '<iframe src="http://www.facebook.com/plugins/like.php?app_id=230521913657215&amp;href=http%3A%2F%2Fwww.facebook.com%2FNhomMua.Cantho&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>';
                 break;
         }

         
         $("dSharingBottom").style.display = "block"; 
     }

 }
 /******************************************************************************/



 /******************************************************************************/
 /******************************************************************************/
 function resizeBox() {
     //     try {
     //         if ($('div_ShowPopup')) {
     //             var box = $('div_ShowPopup');
     //             if (box && box.visible()) {
     //                 var sizeW = utils.windowSize();
     //                 //var boxL = (sizeW[0] - box.getDimensions().width) / 2;
     //                 var boxT = (sizeW[1] - box.getDimensions().height + 10) / 2;
     //                 //boxL = (boxL > 0 ? boxL : 0);
     //                 boxT = (boxT > 0 ? boxT : 15);
     //                 //box.style.left = boxL + 'px';
     //                 box.style.top = boxT + 'px';
     //             }
     //         }
     //     }
     //     catch (ex) { }

     var h, w;
     if (document.documentElement.scrollWidth <= 990) {
         w = 990;
         h = document.documentElement.scrollHeight;
         $(document.body).style.width = w.toString() + "px";
         
//         if ($("div_BodyMain")) {
//             $("div_BodyMain").style.width = w.toString() + "px";
//         }
//         if ($("div_Shadow")) {
//             $("div_Shadow").style.height = h.toString() + "px";
//             $("div_Shadow").style.width = w.toString() + "px";
//         }
         if ($("dvChiTienDonHangShadow")) {
             $("dvChiTienDonHangShadow").style.width = w.toString() + "px";
         }
     }
     else {
         h = document.documentElement.scrollHeight;
         w = document.documentElement.scrollWidth;
         $(document.body).style.width = "";
         
//         if ($("div_BodyMain")) {
//             $("div_BodyMain").style.width = "";
//         }
//         if ($("div_Shadow")) {
//             $("div_Shadow").style.height = h.toString() + "px";
//             $("div_Shadow").style.width = "";
//         }
         if ($("dvChiTienDonHangShadow")) {
             $("dvChiTienDonHangShadow").style.width = "";
         }
     }

 }

 /******************************************************************************/
 /*************************Code for Time count down*********************************/
 var time;
 var strTimeCountDown = "";
 var hours = 0,
	mins = 0,
	secs = 0;
 function TimeCountDown_List() {

     for (var i = 0; i < arrRemainTime.length; i++) {

         if (arrRemainTime[i] > 0) {
             arrRemainTime[i] = arrRemainTime[i] - 1000;
             if (arrRemainTime[i] <= 0) {
                 window.location = window.location.href;
             }
             else {
                 hours = parseInt(arrRemainTime[i] / 3600000);
                 mins = parseInt((arrRemainTime[i] - (hours * 3600000)) / 60000);
                 secs = parseInt((arrRemainTime[i] - (hours * 3600000) - (mins * 60000)) / 1000);
                 strTimeCountDown = hours + ":" + mins + ":" + secs;
                 $("Time_CountDown_" + arrIDSP[i]).innerHTML = strTimeCountDown;
             }
         }
     }
     time = setTimeout("TimeCountDown_List()", 1000);
 }

 /******************************************************************************/

 function setPopUpCenter(idPopup) {
     var BrowserWidth;
     var BrowserHeight;

     if (typeof window.innerWidth != 'undefined') {// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
         BrowserWidth = window.innerWidth,
        BrowserHeight = window.innerHeight
     }
     // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
     else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
         BrowserWidth = document.documentElement.clientWidth,
        BrowserHeight = document.documentElement.clientHeight
     }
     else {// older versions of IE
         BrowserWidth = document.getElementsByTagName('body')[0].clientWidth,
        BrowserHeight = document.getElementsByTagName('body')[0].clientHeight
     }
     var divHeight = $(idPopup).getHeight();
     var divWidth = $(idPopup).getWidth();
     var top = BrowserHeight > divHeight ? ((BrowserHeight - divHeight) / 2) : 0;
     var left = BrowserWidth > divWidth ? ((BrowserWidth - divWidth) / 2) : 0;
     $(idPopup).setStyle({ "top": top + "px", "position": "absolute", "left": left + "px" });
     window.scrollTo(0, 0);

 }
 function ClosePopup(idPopup) {
     if ($(idPopup)) {
         $(idPopup).style.display = "none";
         $('dShadow').style.display = "none";
     }
 }

 /******************************************************************************/